import 'package:flutter/material.dart';
import '../public.dart';

class BackComponent extends StatelessWidget {
  BackComponent({Key key}) : super(key: key);
  bool canPop(BuildContext context) {
    final NavigatorState navigator = Navigator.of(context);
    return navigator != null && navigator.canPop();
  }

  @override
  Widget build(BuildContext context) {
    return canPop(context)
        ? GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              print('object\$');
              Navigator.pop(context);
            },
            child: Container(
                alignment: Alignment.center,
                child: SVG.icon('arrow_left',
                    size: 20, color: ColorUtil.rgba(255, 255, 255, 0.5))),
          )
        : SizedBox.shrink();
  }
}
